package com.hc.likelistenmusic.bean

data class LocalMusic(
    var path: String,
    var singer: String = "未知歌手",
    var name: String = "未知歌名",
    var album: String = "未知专辑",
    var duration: Int,
    var size: Long,
    var year:String
) {
    var album_img: String? = null
    var selectedType: Int = 1
    lateinit var durationString: String
    fun convertDuration(): String {
        val time = duration / 1000
        if (time < 60) {
            val ts = if (time < 10) {
                "0$time"
            } else {
                "$time"
            }
            return "00:$ts"
        } else if (time in 59..3599) {
            val miao = time % 60
            val miaos: String
            miaos = if (miao < 10) {
                "0$miao"
            } else {
                "$miao"
            }
            val min = time / 60
            val mins: String
            mins = if (min < 10) {
                "0$min"
            } else {
                "$min"
            }
            return "$mins:$miaos"
        } else {
            val h = time / 3600
            val hs: String
            hs = if (h < 10) {
                "0$h"
            } else {
                "$h"
            }
            val m = time % 3600
            if (m < 60) {
                val miaos: String = if (m < 10) {
                    "0$m"
                } else {
                    "$m"
                }
                return "$hs:00:$miaos"
            } else {
                val miao = m % 60
                val miaos: String = if (miao < 10) {
                    "0$miao"
                } else {
                    "$miao"
                }
                val min = m / 60
                val mins: String = if (min < 10) {
                    "0$min"
                } else {
                    "$min"
                }
                return "$hs:$mins:$miaos"
            }
        }
    }
}
